package DAO.impl;

import DAO.IGoodDAO;
import adapters.GoodsAdapter;
import logic.Good;

import java.util.List;

public class GoodDAOImpl implements IGoodDAO {

    private GoodsAdapter goodsAdapter;

    public GoodDAOImpl() {
        this.goodsAdapter = new GoodsAdapter(Good.class);
    }

    @Override
    public void addGood(Good good) {
        goodsAdapter.add(good);
    }

    @Override
    public void addGoods(List<Good> goods) {
        goodsAdapter.addAll(goods);
    }

    public void updateGood (Good good) {
        goodsAdapter.update(good);
    }

    @Override
    public void updateGoods(List<Good> goods) {
        goodsAdapter.updateAll(goods);
    }

    @Override
    public Good getGoodById(int id) {
        return goodsAdapter.getObjectById(id);
    }

    @Override
    public List<Good> getAllGoods() {
        return goodsAdapter.getAll();
    }

    @Override
    public void deleteGood(Good good) {
        goodsAdapter.delete(good);
    }

    @Override
    public void deleteGoods(List<Good> goods) {
        goodsAdapter.deleteAll(goods);
    }

    public void deleteAllGoods(){
        goodsAdapter.deleteAll();
    }
}

